/*
#include <avr/interrupt.h>

#include "ThermometerHandler.h"
#include "UsartHandler.h"
#include "DisplayHandler.h"
#include "EncoderHandler.h"
#include "RelayHandler.h"
#include "Registers.h"

volatile unsigned char rx_flag = 0;
volatile unsigned char rx_data = 0;
volatile unsigned char tx_flag = 0;
volatile unsigned char tx_data = 0;

ISR(USART_RXC_vect)
{
	rx_data = UDR;
	rx_flag = 1;
}

ISR(USART_TXC_vect)
{
	if(tx_flag)
	{
		tx_flag = 0;
		UDR = tx_data;
	}
}

int main()
{
	UsartHandler::initialize();
	sei();
	
	Registers encoder_config;
	encoder_config.ddr  = &DDRD;
	encoder_config.pin  = &PIND;
	encoder_config.port = &PORTD;
	
	// since both pins & button of encoder are using same registers, we can use same instance of registers class in constructor
	EncoderHandler		encoder(encoder_config, PD4, encoder_config, PD3, encoder_config, PD2);
	
	RelayHandler		relay(&DDRD, &PORTD, PD7);
	ThermometerHandler	termometer(&DDRB, &PINB, PB0);
	
	DisplayConfig config;
	
	config.rs_bit   = PC0;
	config.e_bit    = PC1;
	config.db4_bit  = PC2;
	config.db5_bit  = PC3;
	config.db6_bit  = PC4;
	config.db7_bit  = PC5;
	
	config.rs_ddr   = &DDRC;
	config.e_ddr    = &DDRC;
	config.db4_ddr  = &DDRC;
	config.db5_ddr  = &DDRC;
	config.db6_ddr  = &DDRC;
	config.db7_ddr  = &DDRC;
	
	config.rs_port  = &PORTC;
	config.e_port   = &PORTC;
	config.db4_port = &PORTC;
	config.db5_port = &PORTC;
	config.db6_port = &PORTC;
	config.db7_port = &PORTC;	
	
	DisplayHandler		display(config);	

	for(;;)
	{
		uint8_t tackt = encoder.read();
		
		if(tackt != neutral)
		{
			display.clear();
			if(tackt == left)
			{
				termometer.start_measurement();
				char buf[10];
				termometer.get_result(buf);
				display.write_text(buf);
			}				 				
			else if(tackt == right)
			{
				relay.disable();
				display.write_text("relay disabled");
			}
			else if(tackt == click)
			{
				relay.enable();
				display.write_text("relay enabled");
			}
		}
	}
	return 0;
}
*/